package org.hbgl.geoentity.db.service;

import com.github.pagehelper.PageHelper;
import org.hbgl.geoentity.db.dao.GeColumnMapper;
import org.hbgl.geoentity.db.domain.GeColumn;
import org.hbgl.geoentity.db.vo.ColumnBoxVo;
import org.hbgl.geoentity.db.vo.ColumnVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 代码功能：
 * 开发日期：2022/4/26
 * 作者：蒋海仑
 * 联系方式：
 * 版本更迭说明：
 * 版权信息：河北广联信息技术有限公司
 */
@Service
public class GeColumnService {
    @Resource
    private GeColumnMapper columnMapper;

    public List<ColumnVo> selectColumnList(String name, Integer page, Integer limit) {
        PageHelper.startPage(page, limit);
        return columnMapper.selectColumnList(name);
    }

    public List<ColumnBoxVo> columnBox() {
        return columnMapper.selectColumnBoxList();
    }

    public List<GeColumn> findByColumnName(Integer parentId, String name) {
        return columnMapper.findByColumnName(parentId, name);
    }

    public int insertColumn(GeColumn column) {
        column.setAddTime(LocalDateTime.now());
        column.setEditTime(LocalDateTime.now());
        return columnMapper.insertColumn(column);
    }

    public ColumnVo findColumnById(Integer id) {
        return columnMapper.findColumnById(id);
    }

    public int deleteColumnById(Integer id) {
        return columnMapper.deleteColumnById(id);
    }

    public int updateColumn(GeColumn geColumn) {
        geColumn.setEditTime(LocalDateTime.now());
        return columnMapper.updateByExampleSelective(geColumn);
    }
    public List<GeColumn> selectColumnByParentId(Integer parentId) {
        return columnMapper.selectSiteColumnByParentId(parentId);
    }


}
